﻿@{
    Layout = null;

    int Type = int.Parse(ViewData["Type"].ToString());
}
@model  YQGL.Model.DL_QY

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>

    <!-- Bootstrap framework -->
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css" />
    <!-- jQuery UI theme -->
    <link rel="stylesheet" href="/lib/jquery-ui/css/Aristo/Aristo.css" />
    <!-- tooltips-->
    <link rel="stylesheet" href="/lib/jBreadcrumbs/css/BreadCrumb.css" />
    <!-- tooltips-->
    <link rel="stylesheet" href="/lib/qtip2/jquery.qtip.min.css" />
    <!-- colorbox -->
    <link rel="stylesheet" href="/lib/colorbox/colorbox.css" />
    <!-- code prettify -->
    <link rel="stylesheet" href="/lib/google-code-prettify/prettify.css" />
    <!-- sticky notifications -->
    <link rel="stylesheet" href="/lib/sticky/sticky.css" />
    <!-- aditional icons -->
    <link rel="stylesheet" href="/img/splashy/splashy.css" />
    <!-- flags -->
    <link rel="stylesheet" href="/img/flags/flags.css" />
    <!-- datatables -->
    <link rel="stylesheet" href="/lib/datatables/extras/TableTools/media/css/TableTools.css">

    <!-- calendar -->
    <link rel="stylesheet" href="/lib/fullcalendar/fullcalendar_gebo.css" />

    <!-- main styles -->
    <link rel="stylesheet" href="/css/style.css" />
    <!-- theme color-->
    <link rel="stylesheet" href="/css/blue.css" id="link_theme" />

    <!--             <link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'> -->
    <!-- favicon -->
    <link rel="shortcut icon" href="favicon.ico" />



    <script src="/Scripts/jquery.min.js"></script>
    <script src="/Scripts/jquery-migrate.min.js"></script>
    <script src="/lib/jquery-ui/jquery-ui-1.10.0.custom.min.js"></script>
    <!-- touch events for jquery ui-->
    <script src="/Scripts/forms/jquery.ui.touch-punch.min.js"></script>
    <!-- easing plugin -->
    <script src="/Scripts/jquery.easing.1.3.min.js"></script>
    <!-- smart resize event -->
    <script src="/Scripts/jquery.debouncedresize.min.js"></script>
    <!-- js cookie plugin -->
    <script src="/Scripts/jquery_cookie_min.js"></script>
    <!-- main bootstrap js -->
    <script src="/bootstrap/js/bootstrap.min.js"></script>
    <!-- bootstrap plugins -->
    <script src="/Scripts/bootstrap.plugins.min.js"></script>
    <!-- typeahead -->
    <script src="/lib/typeahead/typeahead.min.js"></script>
    <!-- code prettifier -->
    <script src="/lib/google-code-prettify/prettify.min.js"></script>
    <!-- sticky messages -->
    <script src="/lib/sticky/sticky.min.js"></script>
    <!-- tooltips -->
    <script src="/lib/qtip2/jquery.qtip.min.js"></script>
    <!-- lightbox -->
    <script src="/lib/colorbox/jquery.colorbox.min.js"></script>
    <!-- jBreadcrumbs -->
    <script src="/lib/jBreadcrumbs/js/jquery.jBreadCrumb.1.1.min.js"></script>
    <!-- hidden elements width/height -->
    <script src="/Scripts/jquery.actual.min.js"></script>
    <!-- custom scrollbar -->
    <script src="/lib/slimScroll/jquery.slimscroll.js"></script>
    <!-- fix for ios orientation change -->
    <script src="/Scripts/ios-orientationchange-fix.js"></script>
    <!-- to top -->
    <script src="/lib/UItoTop/jquery.ui.totop.min.js"></script>
    <!-- mobile nav -->
    <script src="/Scripts/selectNav.js"></script>
    <!-- common functions -->
    @*<script src="/Scripts/gebo_common.js"></script>*@
    <!-- validation -->
    <script src="/lib/validation/jquery.validate.js"></script>
    <!-- wizard -->
    <script src="/lib/stepy/js/jquery.stepy.min.js"></script>
    <!-- wizard functions -->
    @*<script src="/Scripts/gebo_wizard.js"></script>*@

    <script src="@Url.Content("~/Scripts/json2.js")" type="text/javascript"></script>
    <!--[if lt IE 9]>
        <script src="/js/respond.min.js"></script>


    <![endif]-->

    <script type="text/javascript">

        var thevid;
        $(document).ready(function () {

            
        });




        function valdt() {
            thevid = $('#form1').validate({
                onkeyup: false,
                errorClass: 'error',
                validClass: 'valid',
                rules: {
                    oldPassword: {
                        required: @Html.Raw(Type==0?"true":"false"),
                        minlength: 6

                    },
                    newPassword: {
                        required: true,
                        minlength: 6,
                        equalTo: "#newPassword1"

                    },
                    newPassword1: {
                        required: true,
                        minlength: 6,
                        equalTo: "#newPassword"

                    }
                },
                highlight: function (element) {
                    $(element).closest('div').addClass("f_error");
                },
                unhighlight: function (element) {
                    $(element).closest('div').removeClass("f_error");

                },
                errorPlacement: function (error, element) {
                    $(element).closest('div').append(error);


                },
                messages: {

                    oldPassword: {
                        required: "请填写正确的旧密码",
                        minlength: "必须大于6个字符"

                    },

                    newPassword: {
                        required: "请填写正确的密码",
                        minlength: "必须大于6个字符",
                        equalTo: "2次输入新密码必须相同"

                    },
                    newPassword1: {
                        required: "请填写正确的密码",
                        minlength: "必须大于6个字符",
                        equalTo: "2次输入新密码必须相同"

                    }
                }

            });

        }

        function save() {

            valdt()
            if (thevid.form()) {


                $.ajax({
                    type: 'POST',
                    url: '@Url.Action("EditPassword", "Password")',
                    data: $('#form1').serialize(),
                    success: function (result) {
                        if (result == "ok") {
                            alert("修改密码成功");
                            if($("#hdType").val()=="1")
                            {
                                window.location.href = '@Url.Action("Index", "Home")';
                            }else
                            {
                                window.location.reload();
                            }
                        } else {
                            alert(result);
                        }
                    }
                });


            }
        }
        function iframeAutoFit() {
            var ex;
            try {
                if (window != parent) {
                    var a = parent.document.getElementsByTagName("iframe");
                    for (var i = 0; i < a.length; i++) {
                        if (a[i].contentWindow == window) {
                            var h1 = 0, h2 = 0;
                            if (document.documentElement && document.documentElement.scrollHeight) {
                                h1 = document.documentElement.scrollHeight;
                            }
                            if (document.body) h2 = document.body.scrollHeight;
                            var h = Math.max(h1, h2);
                            if (window.ActiveXObject) { h += 4; }
                            else { h += 4; }
                            a[i].style.height = h + "px";
                            window.removeEventListener('resize', iframeAutoFit, false); //兼容谷歌浏览器时要去掉RISZE监听
                        }
                    }
                }
            }
            catch (ex) { }
        }
    </script>


</head>
<body style="overflow-x:hidden">



    <div style="max-width:700px;margin-left:auto;margin-right:auto">

        <h3 class="heading">密码修改</h3>
        <div class="row ">

            <div class="col-sm-offset-1 col-sm-5 ">


                <form class="form-horizontal" role="form" id="form1">
                    @Html.Hidden("hdType",Type)
                    <div class="form-group">

                        <label class="col-xs-4 control-label input-sm text-right"> 用户名:</label>
                        <div class="col-xs-8 ">
                            <input type="text" class="form-control  input-sm" id="FUserName " disabled="disabled" value="@Model.QYBM">
                        </div>

                    </div>
                    @if(Type==0)
                    { 
                    <div class="form-group">

                        <label class="col-xs-4 control-label input-sm text-right">
                            原始密码:<span class="f_req">*</span>
                        </label>
                        <div class="col-xs-8 ">
                            <input type="password" class="form-control  input-sm" id="oldPassword" name="oldPassword" placeholder="">
                        </div>

                    </div>
                    }
                    <div class="form-group ">
                        <label class="col-xs-4 control-label input-sm text-right">
                            新密码:<span class="f_req">*</span>
                        </label>
                        <div class="col-xs-8 ">
                            <input type="password" class="form-control  input-sm" id="newPassword" name="newPassword" placeholder="">
                        </div>
                    </div>
                    <div class="form-group ">
                        <label class="col-xs-4 control-label input-sm text-right">
                            新密码确认:<span class="f_req">*</span>
                        </label>
                        <div class="col-xs-8">
                            <input type="password" class="form-control  input-sm" id="newPassword1" name="newPassword1">


                        </div>
                    </div>
                    <div class="form-group ">
                        <div class=" col-sm-7 text-right">



                            <button type="button" class="btn btn-success " onclick=" save();">保存</button>

                        </div>
                        <div class=" col-sm-5 text-center">

                            <button type="button" class="btn btn-info" onclick="window.location.reload()">取消</button>
                        </div>
                        </div>


                    </div>
                </form>
            </div>

        </div>
   
</body>
</html>
